package com.huirui.server.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import lombok.Data;

import java.util.List;

@Data
@Schema(description = "订单创建请求参数")
public class OrderCreateDto {

    @NotNull(message = "收货地址ID不能为空")
    @Schema(description = "收货地址ID", example = "123456", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long deliveryAddressId;

    @Schema(description = "订单备注信息", example = "请在工作日送货", maxLength = 500)
    private String notes;

    @NotEmpty(message = "订单商品列表不能为空")
    @Valid
    @Schema(description = "订单商品列表", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<OrderProductItem> productItemList;

    @Schema(description = "订单商品项，包含商品规格和数量信息")
    public static class OrderProductItem {

        @NotNull(message = "商品规格ID不能为空")
        @Schema(description = "商品规格ID", example = "7890", requiredMode = Schema.RequiredMode.REQUIRED)
        public Long productSpecificationId;

        @NotNull(message = "商品数量不能为空")
        @Positive(message = "商品数量必须大于0")
        @Schema(description = "商品购买数量", example = "2", minimum = "1", requiredMode = Schema.RequiredMode.REQUIRED)
        public Long quantity;
    }
}
